package com.zmx.doctor.view.activity;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.zmx.doctor.BaseActivity;
import com.zmx.doctor.R;
import com.zmx.doctor.fragment.registration_list.ProcessedFragment;
import com.zmx.doctor.fragment.registration_list.UntreatedFragment;

import java.util.ArrayList;
import java.util.List;

/**
*时间：2020/6/14 11:23
*功能：挂号列表
*/
public class RegistrationListActivity extends BaseActivity {

    static final int NUM_ITEMS = 2;
    private List<Fragment> fragmentList = new ArrayList<Fragment>();
    private String[] strings = new String[]{"待处理","已处理"};

    @Override
    protected int getLayoutId() {

        return R.layout.activity_registration_list;

    }

    @Override
    protected void initViews() {

        setToolbar(R.id.tool_bar);
        ProcessedFragment pf = new ProcessedFragment();
        UntreatedFragment uf = new UntreatedFragment();
        fragmentList.add(uf);
        fragmentList.add(pf);

        TabLayout tab_layout = findViewById(R.id.tab_layout);
        ViewPager viewPager = findViewById(R.id.viewPager);
        RegistrationListActivity.MyAdapter fragmentAdater = new RegistrationListActivity.MyAdapter(getSupportFragmentManager());
        viewPager.setAdapter(fragmentAdater);
        tab_layout.setupWithViewPager(viewPager);

    }


    public class MyAdapter extends FragmentPagerAdapter {
        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return NUM_ITEMS;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Nullable
        @Override
        public CharSequence getPageTitle(int position) {
            return strings[position];
        }
    }

}